package com.example.driving.ui.adapter;

import android.graphics.drawable.Drawable;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.driving.R;
import com.example.driving.base.App;
import com.example.driving.model.ExamQuestionBean;

import java.util.List;

public class BottomListAdapter extends BaseQuickAdapter<ExamQuestionBean, BaseViewHolder> {
    private int curPosition;

    public BottomListAdapter(List<ExamQuestionBean> data) {
        super(R.layout.item_num, data);
    }


    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, ExamQuestionBean questionVo) {
        baseViewHolder.setText(R.id.tv_num, baseViewHolder.getBindingAdapterPosition() + 1 + "");
        if (curPosition == baseViewHolder.getBindingAdapterPosition()) {//选中状态
            TextView tv_num = baseViewHolder.getView(R.id.tv_num);
            int text_selected = App.getmContext().getResources().getColor(R.color.ang_white);
            Drawable background_selected = App.getmContext().getResources().getDrawable(R.drawable.bg_cercle_blue);
            tv_num.setTextColor(text_selected);
            tv_num.setBackground(background_selected);
        } else {//未选中状态
            TextView tv_num = baseViewHolder.getView(R.id.tv_num);
            int text_selected = App.getmContext().getResources().getColor(R.color.ang_text_base);
            Drawable background_selected = App.getmContext().getResources().getDrawable(R.drawable.learn_topic_num_nor);
            tv_num.setTextColor(text_selected);
            tv_num.setBackground(background_selected);
        }
    }


    public void setCurPosition(int curPosition) {
        this.curPosition = curPosition;
        notifyDataSetChanged();//刷新适配器
    }


}
